/**
 * @file main.c
 * @author MonkeyPi (https://makerinchina.cn)
 * @brief miniblink example
 * @version 0.1
 * @date 2022-08-19
 * 
 * @copyright Copyright (c) 2022
 * 
 */

#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>

int main(void) {
        rcc_periph_clock_enable(RCC_GPIOC);
#if defined(STM32F1) /* F1 is a precious snowflake */
	gpio_set_mode(RCC_GPIOC, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO13);
#else /* everyone else is sane */
        gpio_mode_setup(RCC_GPIOC, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO13);
#endif
	gpio_set(RCC_GPIOC, GPIO13);

	while(1) {
		/* wait a little bit */
		for (int i = 0; i < 5000; i++) {
			__asm__("nop");
		}
		gpio_toggle(RCC_GPIOC, GPIO13);

	}
}
